(function(angular) {
	"use strict";
	angular.module("fs.waf").controller("cls.popup.glentry.viewGLController", viewGLController);
	viewGLController.$inject = [ "$scope", "$uibModalInstance", "dialogsModule", "gridService", "layoutConfig", "validatorConfig", "authService" ];
	function viewGLController($scope, $uibModalInstance, dialogsModule, gridService, layoutConfig, validatorConfig, authService) {
		var ctrl = this;
		ctrl.dialogsModule = dialogsModule;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		ctrl.glentryList = {};
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback["close"] || dialogsModule.btnCallback["close"]() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			ctrl.gridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.tableConfigs.table, null);
			ctrl.gridOptions.data = "vm.searchCriteria.list";
			ctrl.searchCriteria = {};
			ctrl.searchCriteria.txnId = ctrl.dialogsModule.params.txnId;
			ctrl.searchCriteria.txnType = ctrl.dialogsModule.params.txnType;
			ctrl.search();
		};
		
		
		ctrl.search = function() {
			ctrl.searchCriteria.list = [];
			authService.getGlEntry(ctrl.searchCriteria).then(function(response) {
				angular.merge(ctrl.searchCriteria, response.data);
			}, angular.noop);
		};
		
	}
})(angular);
